//package com.example.demo.common;
//
//
//import org.springframework.stereotype.Component;
//
//import javax.servlet.*;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//
//@Component
//public class MyFilter implements Filter {
//
//    @Override
//    public void init(FilterConfig filterConfig) throws ServletException {
//        // 初始化方法
//    }
//
//    @Override
//    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
//            throws IOException, ServletException {
//        HttpServletRequest httpRequest = (HttpServletRequest) request;
//        String requestURI = httpRequest.getRequestURI();
//        if (requestURI.contains("/login")) {
//            // 如果请求 URL 包含 "/login"，则放行
//            chain.doFilter(request, response);
//        } else {
//            // 如果请求 URL 不包含 "/login"，则返回错误信息
//            HttpServletResponse httpResponse = (HttpServletResponse) response;
//            httpResponse.setContentType("application/json;charset=UTF-8");
//            httpResponse.getWriter().write("非法请求！");
//            return;
//        }
//    }
//
//    @Override
//    public void destroy() {
//        // 销毁方法
//    }
//
//}
